#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int a[N], b[N];
int n, m;
int main()
{
    int x;
    cin >> n >> m >> x;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
    }
    int i = 1, j = m;
    while (i <= n && j >= 1) {
        if (a[i] + b[j] == x) {
            cout << i - 1 << " " << j - 1 << endl;
            return 0;
        }
        else if (a[i] + b[j] > x) {
            j--;
        }
        else {
            i++;
        }
    }
    return 0;
}